package sym.qrcode;

import java.util.Hashtable;

public final class ResultMetadataType {

	private static final Hashtable VALUES = new Hashtable();

	/**
	 * <p>
	 * 2D barcode formats typically encode text, but allow for a sort of 'byte
	 * mode' which is sometimes used to encode binary data. While {@link Result}
	 * makes available the complete raw bytes in the barcode for these formats,
	 * it does not offer the bytes from the byte segments alone.
	 * </p>
	 * 
	 * <p>
	 * This maps to a {@link java.util.Vector} of byte arrays corresponding to
	 * the raw bytes in the byte segments in the barcode, in order.
	 * </p>
	 */
	public static final ResultMetadataType BYTE_SEGMENTS = new ResultMetadataType(
			"BYTE_SEGMENTS");

	/**
	 * Error correction level used, if applicable. The value type depends on the
	 * format, but is typically a String.
	 */
	public static final ResultMetadataType ERROR_CORRECTION_LEVEL = new ResultMetadataType(
			"ERROR_CORRECTION_LEVEL");

	/**
	 * Decrypt the encrypted content.
	 */
	public static final ResultMetadataType DECRYPTED_CONTENT = new ResultMetadataType(
			"ENCRYPTED_CONTENT");

	private final String name;

	private ResultMetadataType(String name) {
		this.name = name;
		VALUES.put(name, this);
	}

	public String getName() {
		return name;
	}

	public String toString() {
		return name;
	}

	public static ResultMetadataType valueOf(String name) {
		if (name == null || name.length() == 0) {
			throw new IllegalArgumentException();
		}
		ResultMetadataType format = (ResultMetadataType) VALUES.get(name);
		if (format == null) {
			throw new IllegalArgumentException();
		}
		return format;
	}

}
